(function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(require,module,exports){
"use strict";

loader.define(function (require, exports, module, global) {
  this.pageview = {};

  this.pageview.init = function () {
    // console.log($('.morebui .morepage'))
    var storage;
    storage = bui.storage({
      size: 0
    });
    var getParams = bui.getPageParams();
    getParams.done(function (result) {
      var msg_ = result['msg'];
      var type = result['type'];

      if (msg_ instanceof Array) {
        storage.clear();
        storage.set("title", type);

        for (var i in msg_) {
          storage.set("activity", msg_[i], "id");
        }
      }
    }); // 取到数据了

    $(".morepage header .bui-bar .header-title").text(storage.get("title"));
    var msg = storage.get("activity");
    console.log(msg);
    var container;

    for (var i in msg) {
      if (i % 3 == 0) {
        container = $('<div class="bui-box item-container"></div>');
      }

      var span4 = $('<div class="span4"></div>');
      var itembtn = $('<div class="item bui-btn"></div>');
      itembtn.attr("id", i);
      var item = msg[i]['name'];
      var itemname = $('<div class="item-name"></div>');
      itemname.text(item);
      var itemdis = $('<div class="bui-box-align-middle item-detail item-dis"><img src="images/search/place_16.png"><div>' + msg[i]['distance'] + msg[i]['unit'] + '</div></div>');
      var itemview = $('<div class="bui-box-align-middle item-detail"><img src="images/search/look_16.png"><div>' + msg[i]['pageview'] + '</div></div>');
      var full = $('<i class="icon-tag"><img src="images/search/full.png"></i>');
      var involve = $('<i class="icon-tag"><img src="images/search/involve.png"></i>');
      itembtn.append(itemname);
      itembtn.append(itemdis);
      itembtn.append(itemview);
      if (msg[i]['peoplesurplus'] <= 0) itembtn.append(full);
      if (msg[i]['is_involved']) itembtn.append(involve);
      span4.append(itembtn);
      container.append(span4);

      if (i % 3 == 2 || i == msg.length - 1) {
        if (i == msg.length - 1) {
          for (var k = 1; k < 3 - i % 3; k++) {
            container.append($('<div class="span4"></div>'));
          }
        }

        $('.morepage main').append(container);
      }
    }

    $(".item").on("click", function () {
      // alert($(this).attr("id"));
      var num = $(this).attr("id"); // console.log(storage.get("activity", parseInt(num)));

      var mes = storage.get("activity", parseInt(num));
      console.log(mes);
      var id = mes['id'];
      var lng = mes['lng'];
      var lat = mes['lat'];
      var type = storage.get("title")[0];
      console.log(id);
      console.log(lng);
      console.log(lat);
      console.log(type);
      bui.load({
        url: "pages/activitydetail/activitydetail",
        param: {
          id: id,
          type: type,
          lng: lng,
          lat: lat
        }
      });
    });
  };

  this.pageview.init();
  return this.pageview;
});
},{}]},{},[1]);
